﻿using GalaSoft.MvvmLight;
using System.Diagnostics;

namespace SimpleJackInterface.ViewModel
{

    public enum eChatter
    {
        Unknown,

        SimpleJack,
        User
    }

    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class ChatLogItemViewModel : ViewModelBase
    {

        /// <summary>
        /// Initializes a new instance of the ChatLogItemViewModel class.
        /// </summary>
        public ChatLogItemViewModel(eChatter chatter, string message)
        {
            this.Chatter = chatter;
            this.Message = message;

            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real": Connect to service, etc...
            ////}
        }

        ////public override void Cleanup()
        ////{
        ////    // Clean own resources if needed

        ////    base.Cleanup();
        ////}

        
        #region Chatter Property
        /// <summary>
        /// The <see cref="Chatter" /> property's name.
        /// </summary>
        public const string ChatterPropertyName = "Chatter";

        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private eChatter _Chatter = eChatter.Unknown;

        /// <summary>
        /// Gets the Chatter property.
        /// TODO Update documentation:
        /// Changes to that property's value raise the PropertyChanged event. 
        /// This property's value is broadcasted by the Messenger's default instance when it changes.
        /// </summary>
        public eChatter Chatter
        {
            get
            {
                return _Chatter;
            }

            set
            {
                if (_Chatter == value)
                {
                    return;
                }

                var oldValue = _Chatter;
                _Chatter = value;

                // Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging
                RaisePropertyChanged(ChatterPropertyName, oldValue, value, true);
            }
        }
        #endregion

        #region Message Property
        /// <summary>
        /// The <see cref="Message" /> property's name.
        /// </summary>
        public const string MessagePropertyName = "Message";

        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private string _Message = "";

        /// <summary>
        /// Gets the Message property.
        /// TODO Update documentation:
        /// Changes to that property's value raise the PropertyChanged event. 
        /// This property's value is broadcasted by the Messenger's default instance when it changes.
        /// </summary>
        public string Message
        {
            get
            {
                return _Message;
            }

            set
            {
                if (_Message == value)
                {
                    return;
                }

                var oldValue = _Message;
                _Message = value;

                // Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging
                RaisePropertyChanged(MessagePropertyName, oldValue, value, true);
            }
        }
        #endregion

    }
}